export function toTrees(pid, arr) {
  function loop(curId) {
    const result = [];
    arr.forEach((res) => {
      if (curId === res.parentId) {
        res.children = loop(res.id);
        result.push(res);
      }
    });
    return result;
  }

  return loop(pid);
}
